package com.huawei.Galenus.dao;

import com.huawei.Galenus.domain.Auth;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AuthRepository {

    @Insert("insert into auth values(#{id},#{pid},#{authtime},#{authfilehash}," +
            "#{authsign},#{hash},#{price},#{description},#{status},#{uid},#{creator})")
    int save(Auth auth);

    @Update("update auth set status=#{status} where id=#{aid}")
    Integer updateStatusById(@Param("aid") String aid, @Param("status") int status);

    @Select("select * from auth where uid=#{uid}")
    List<Auth> selectMyBoughtAuth(@Param("uid") Integer uid);

    @Select("select * from auth where creator=#{uid}")
    List<Auth> selectMyAuth(@Param("uid") String uid);

    @Select("select * from auth where id=#{aid}")
    Auth selectById(@Param("aid") String aid);
}
